/**
 * 
 */
package org.bf.sms.webservice;

import java.util.List;

import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.bf.sms.config.SysConfig;
import org.bf.sms.domain.message.Message;


/**
 * 发送短信
 * 
 * @author LiuChang
 * @version
 * @since
 */
public class SMSClient
{

	/**
	 * 发送短信
	 * 
	 * @param messages
	 */
	public static void sendMessage(List<Message> messages)
	{
		// 初始化WebService请求
		JaxWsProxyFactoryBean svr = new JaxWsProxyFactoryBean();
		svr.setServiceClass(SMSServer.class);
		svr.setAddress(SysConfig.WS_ADDRESS);

		// 创建服务
		SMSServer sm = (SMSServer) svr.create();
		Message message = new Message();

		System.out.println(sm.sendList(messages));
	}

	/**
	 * 短信发送WebService测试
	 * 
	 * @param args
	 *            参数
	 */
	public static void main(String[] args)
	{
		JaxWsProxyFactoryBean svr = new JaxWsProxyFactoryBean();
		svr.setServiceClass(SMSServer.class);
		svr.setAddress("http://localhost:9090/sms");
		SMSServer sm = (SMSServer) svr.create();
		Message message = new Message();
		message.setContent("Fantastic!");
		System.out.println(sm.sendObject(message));
	}
}
